<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <script th:src="@{/js/jquery-1.10.2.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/echarts.min.js}"></script>
    <title>个人信息</title>
</head>
<body>
<div class="container">
    <!--    header-->
    <div class="row clearfix">
        <div class="col-md-12 column" th:include="common/header.html">
        </div>
    </div>
    <!--    center-->
    <div class="row clearfix">
        <!--        个人中心管理菜单-->
        <div class="col-md-2 column" th:include="common/infoMenu.html">
        </div>
        <!--        个人中心相关管理子界面-->
        <div class="col-md-9 column">
            <h3 class="text-center">
                更改密码
            </h3>
            <form class="form-horizontal" role="form" action="/customer/doUpdatePass" method="POST">
                <div class="form-group">
                    <label for="pass" class="col-sm-4 control-label">原密码*</label>
                    <div class="col-sm-6">
                        <input type="password" name="pass" id="pass" placeholder="请输入原密码" required/><span id="exist"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="pass" class="col-sm-4 control-label">新密码*</label>
                    <div class="col-sm-6">
                        <input type="password" name="newpass" id="newpass" placeholder="请输入新密码" required/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="newpass1" class="col-sm-4 control-label">确认新密码*</label>
                    <div class="col-sm-6">
                        <input type="password" name="newpass1" id="newpass1" placeholder="请再次输入新密码" required/><span id="tp"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="tel" class="col-sm-4 control-label">手机*</label>
                    <div class="col-sm-6">
                        <input type="text" name="tel" id="tel" placeholder="请输入手机号"><span id="exist2"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="yzm" class="col-sm-4 control-label">验证码*</label>
                    <div class="col-sm-6">
                        <input type="text" name="yzm" id="yzm" placeholder="请输入验证码"><input type="button" value="发送验证码">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-4 col-sm-5">
                        <button type="submit" class="btn btn-default btn-primary" style="width:150px">更新</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>
<div class="row clearfix">
    <div class="col-md-12 column" th:include="common/footer.html">
    </div>
</div>
</body>
<script>
    $(function () {
        var oldpass = $("#pass");//选取账号输入

        oldpass.blur(function () {
            //
            //异步送出数据，至控制层，测试是否存在此账号
            $.ajax({
                type: "post", //访问方式
                url: "/customer/passIsCorrect", //访问路径
                data: {//传入服务端的数据
                    "pass": oldpass.val()
                },
                dataType: "json",
                //调整成功后事件 message为服务器返回的值
                success: function (message) {
                    if (message == 0) {
                        //对象获得焦点
                        oldpass.focus();
                        //给对象内容赋值
                        $('#exist').html("原始密码不对");
                        // $('#tj').enabled(false);
                        //更改对象样式
                        $('#exist').css("color", "red");
                    } else {
                        $('#exist').html("");
                        // $('#tj').disable(false);
                    }
                },
                //若调用错误，则执行此事件
                error: function (err) {
                    alert("请求出错了" + JSON.stringify(err));
                }
            });//end of ajax
        });//end of blur

        var newpass1 = $("#newpass1");//选取账号输入

        newpass1.blur(function () {
            //
            //异步送出数据，至控制层，测试是否存在此账号
            $.ajax({
                type: "post", //访问方式
                url: "/customer/pswIsCorrect", //访问路径
                data: {//传入服务端的数据
                    "newpass1": newpass1.val()
                },
                dataType: "json",
                //调整成功后事件 message为服务器返回的值
                success: function () {
                        if($("#newpass").val()!=$("#newpass1").val()){
                            $('#tp').html("二次密码不一致");
                            $('#tp').css("color", "red");
                            newpass1.focus();
                        }else{
                            $('#tp').html("");
                            // $('#tp').css("color", "red");
                        }
                },
                //若调用错误，则执行此事件
                error: function (err) {
                    alert("请求出错了" + JSON.stringify(err));
                }
            });//end of ajax
        });//end of blur

    })
</script>
</html>